<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			div {
				width: 200px;
				height: 200px;
				background-color: black;
				float: left;
				margin: 50px;
			}
		</style>
	</head>
	<body>
		<div id="div1">1</div>
		<div id="div2">2</div>
		<input type="button" id="btn" value="确定" />
		<script>
			var odiv1 = document.getElementById('div1');
			var odiv2 = document.getElementById('div2');
			var obtn = document.getElementById('btn');
			odiv1.onclick = function() {
				odiv1.style.background = 'red'
			}
			odiv2.onclick = function() {
				odiv2.style.background = 'red'
			}
			obtn.onclick = function() {
				if (odiv1.style.background == "red" || odiv2.style.background == "red") {
					alert('它们其中一个是红色')
				} else {
					alert('它们全是黑色')
				}
			}
		</script>
	</body>
</html>